//
//  UIButton+ZYWebCaches.m
//  BestLearning
//
//  Created by ちょうかんこん on 2017/12/20.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "UIButton+ZYWebCaches.h"

@implementation UIButton (ZYWebCaches)


- (void)zy_setBackgroundImageWithUrl:(NSString *)urlStr{
    
    
    NSURL * url = [NSURL URLWithString:urlStr];
    dispatch_queue_t xrQueue = dispatch_queue_create("loadImage", NULL);
    dispatch_async(xrQueue, ^{
        UIImage * img = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
        dispatch_async(dispatch_get_main_queue(), ^{
            [self setBackgroundImage:img forState:self.state];
        });
    });
    
    
    
    
    
    
}

- (void)zy_setImageWithUrl:(NSString *)urlStr{
    
    
    NSURL * url = [NSURL URLWithString:urlStr];
    dispatch_queue_t xrQueue = dispatch_queue_create("loadImage", NULL);
    dispatch_async(xrQueue, ^{
        UIImage * img = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
        dispatch_async(dispatch_get_main_queue(), ^{
            [self setImage :img forState:UIControlStateNormal];
        });
    });
    
    
    
    
    
    
}



@end
